package com.paas.form.core.element.control;

import com.paas.form.core.element.control.impl.searchItem.*;
import com.paas.form.core.element.field.FieLdsModel;

public class FormItemFactory {
    /**
     * 描述:根据不同字段生成不同的前端元素
     * @param field
     * @return
     */
    public static FormItem create(FieLdsModel field,String htmlType){
        if(htmlType.equals("form")){
            switch (field.getConfig().getPfKey()){
                //useSelectList['radio', 'checkbox', 'select']
                case "radio":
                    return new FormSelectItem(field,htmlType);
                case "checkbox":
                    return new FormSelectItem(field,htmlType);
                case "select":
                    return new FormSelectItem(field,htmlType);
                case "treeSelect":
                    return new PfTreeSelect(field,htmlType);
                case "cascader":
                    return new ElCascaderItem(field,htmlType);
                default:
                    return new DivItem(field,htmlType);

            }
        }


//        String htmlType = "form";

        switch (field.getConfig().getPfKey()){
            //useInputList[comInput,textarea...]
            case "comInput":
                return new FormInputItem(field,htmlType);
            case "textarea":
                return new FormInputItem(field,htmlType);
            case "pfText":
                return new FormInputItem(field,htmlType);
            case "link":
                return new FormInputItem(field,htmlType);
            case "billRule":
                return new FormInputItem(field,htmlType);
            //useDateList[createTime,modifyTime]
            case "createTime":
                return new ElDatePickerItem(field,htmlType);
            case "modifyTime":
                return new ElDatePickerItem(field,htmlType);
            //useSelectList['radio', 'checkbox', 'select']
            case "radio":
                return new FormSelectItem(field,htmlType);
            case "checkbox":
                return new FormSelectItem(field,htmlType);
            case "select":
                return new FormSelectItem(field,htmlType);
            case "numInput":
                return new NumRangeItem(field,htmlType);
            case "calculate":
                return new NumRangeItem(field,htmlType);
//            case "cascader":
//                return new ElCascaderItem(field,htmlType);
            case "time":
                return new ElTimePicker(field,htmlType);
            case "timeRange":
                return new ElTimePicker(field,htmlType);
            case "date":
                return new ElDatePicker(field,htmlType);
            case "dateRange":
                return new ElDatePickerRange(field,htmlType);
            case "address":
                return new PfAddress(field,htmlType);
            case "treeSelect":
                return new PfTreeSelect(field,htmlType);
            case "createUser":
                return new UserSelect(field,htmlType);
            case "modifyUser":
                return new UserSelect(field,htmlType);
//            case "currOrganize":
//                return new ComSelect(field,htmlType);
//            case "comSelect":
//                return new ComSelect(field,htmlType);
            case "currDept":
                return new DepSelect(field,htmlType);
//            case "currPosition":
//                return new PosSelect(field,htmlType);
            case "groupSelect":
                return new GroupSelect(field,htmlType);
            case "roleSelect":
                return new RoleSelect(field,htmlType);
            case "userSelect":
                return new UserSelectMul(field,htmlType);
//            case "usersSelect":   没有该组件
//                return new UsersSelect(field,htmlType);
//            case "posSelect":
//                return new PosSelectMul(field,htmlType);
            case "depSelect":
                return new DepSelectMul(field,htmlType);
            case "switch":
                return new ElSwitch(field,htmlType);
            default:
//                return new DivItem(field,htmlType);
                return new FormInputItem(field,htmlType);
        }





    }
}
